import React, { useEffect, useRef, useState } from 'react'
import { Button, Input } from 'antd'
import Son from './Son.tsx'

const Father: React.FC = () => {
  const myRef = useRef(null)

  const handleClick = () => {
    setParam(param + 1)
    // myRef.current!.focus({
    //   cursor: 'start'
    // })
  }
  const [param, setParam] = useState<number>(1)
  useEffect(() => {
    console.log('aa')
  })
  const handleMessageFromChild = () => {
    return 'abc'
  }
  useEffect(() => {
    console.log('param执行了')
  }, [param])
  useEffect(() => {
    console.log('全局只执行一次')
  }, [])
  const [pa] = useState<string>('abc')

  return (
    <>
      {param}

      <Son param={pa} fun={handleMessageFromChild}/>

      <Input ref={myRef}/>
      <Button type='primary' onClick={handleClick}>aaa</Button>
    </>

  )
}
export default Father
